using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using Entities;
namespace BUS
{
   public class tbLoaitourBUS
    {
        public static void Insert(tbLoaitour lt)
        {
            tbLoaitourDAL ltDAL = new tbLoaitourDAL();
            ltDAL.Insert(lt);
        }
        public static void Update(tbLoaitour lt)
        {
            tbLoaitourDAL ltDAL = new tbLoaitourDAL();
            ltDAL.Update(lt);
        }
        public static void Delete(int iD)
        {
            tbLoaitourDAL ltDAL = new tbLoaitourDAL();
            ltDAL.Delete(iD);
        }
        public static tbLoaitourCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbLoaitourDAL ltDAL = new tbLoaitourDAL();
            return ltDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbLoaitourCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLoaitourDAL ltDAL = new tbLoaitourDAL();
            return ltDAL.Get(cri.Criter, 0, 0, tbLoaitourCollumn.maloaitour.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbLoaitour GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbLoaitourCollumn.maloaitour.ToString(), Condition.EQUAL, iD);
            tbLoaitourDAL ltDAL = new tbLoaitourDAL();
            tbLoaitourCollection ltColl = ltDAL.Get(cri.Criter, 0, 0, tbLoaitourCollumn.maloaitour.ToString(), OrderDirection.ASC.ToString(), out total);
            if (ltColl.Count > 0)
                return ltColl[0];
            return null;
        }
        public static tbLoaitourCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLoaitourDAL ltDAL = new tbLoaitourDAL();
            return ltDAL.Get(cri.Criter, 1, number,
            tbLoaitourCollumn.maloaitour.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbLoaitourCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbLoaitourDAL ltDAL = new tbLoaitourDAL();
            return ltDAL.Get(cri.Criter, 1, number,
            tbLoaitourCollumn.maloaitour.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
